package com.indra.archetypeweb.dao.book;

import java.util.List;

import javax.persistence.PersistenceException;

import com.indra.archetypeweb.dao.base.BaseDaoImpl;
import com.indra.archetypeweb.entity.book.Book;
import com.indra.archetypeweb.entity.user.User;

public class BookDaoImpl extends BaseDaoImpl<Book> implements BookDao {

	@Override
	public List<Book> findAll() {
		
		return em.createNamedQuery(Book.FIND_ALL, Book.class).getResultList();
	}

	@Override
	public List<Book> findByCategory(Long idCategory) {
		try {
			return em.createNamedQuery(Book.FIND_BY_CATEGORY, Book.class)
					.setParameter("idCategory", idCategory).getResultList();
		} catch (PersistenceException e) {
			return null;
		}
	}

}
